package main

import (
	"fmt"
	"gitee.com/love_bass/go-console"
	"go-base/configs"
	"go-base/db"
	"go-base/internal/global"
	"go-base/internal/services/ginserver"
	"go-base/internal/services/udpserver"
)

// @title 加速器接口
// @version 1.0
// @description 加速器管理后台接口文档
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @security ApiKeyAuth
func main() {
	// 初始化配置文件
	configs.Init()
	// 初始化控制台打印实例
	global.Console = console.NewConsole(configs.Data.Main.Console)
	// 初始化数据库
	db.InitDatabase()
	// 启动路由
	go ginserver.Run()

	// 启动udp服务
	server, err := udpserver.NewUDPServer(28082, 10)
	if err != nil {
		fmt.Println("Error creating UDP server:", err)
		return
	}

	err = server.Start()
	if err != nil {
		fmt.Println("Error starting UDP server:", err)
		return
	}

	defer server.Close()

	for clientID := range server.Receive() {
		fmt.Println("go-base received from client:", clientID)
	}
	//——————————————————
}
